import tkinter as tk
import netRequests
from abc import ABC

class uiHandle(tk.Frame):

    def __init__(self, *args, **kargs):
        tk.Frame.__init__(self, *args, **kargs)
        # self.tkroot = tkroot
        self.master.geometry("800x600")
        self.master.title("Hello Dict.")
        self.pack(expand = True)
        self.input1 = tk.Entry(self, width = 200)
        self.input1.pack(padx = 20)
        self.buttonSend = tk.Button(self, text = "Search", command = self.query)
        self.buttonSend.pack()
        self.textReview = ROText(self, bg=None, border=1)
        self.textReview.pack(after = self.buttonSend, pady = 30, fill = 'y')

    def query(self):
        urlList = ["youdao"]
        queryObject = getattr(netRequests, urlList[0])
        getText = queryObject(self.input1.get()).get_result()
        self.textReview.delete("1.0", "end")
        self.textReview.insert("1.0", getText)
        pass

class ROText(tk.Text):
    def __init__(self, *args, **kargs):
        tk.Text.__init__(self, *args, **kargs)
        self.bind("<Key>", lambda e: "break")
        # https://stackoverflow.com/questions/10817917/how-to-disable-input-to-a-text-widget-but-allow-programatic-input


if __name__ == '__main__':
    root = tk.Tk()
    uiHandle(root, height=800, width=600)
    root.mainloop()